package com.lh.learning.mq.rabbitmq;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * @author luohuan
 * @date 2020/6/18
 **/
@Component
public class RabbitMqConsumer {

    @RabbitListener(queues = "message")
//    @SendTo("direct.message/reply.routing")
    public void showMsg(String msg) {
        try {
            System.out.println(1 / 0);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        System.out.println("接收到消息：" + msg);
//        return "haha";
    }

    @RabbitListener(queues = "delayed.message")
    public void showDelayedMsg(String msg) {
        System.out.println("接收到delayed消息：" + msg);
    }
//
//    @RabbitListener(queues = "message")
//    public void showMsg3(String msg) {
//        System.out.println("接收到消息3：" + msg);
//    }

    @RabbitListener(queues = "reply.message")
    public void showReplyMsg(String msg) {
        System.out.println("接收到Reply消息：" + msg);
    }
}
